/**
 * Project: springyounger.lottery.dal
 * 
 * File Created at 2010-3-26
 * $Id$
 * 
 * Copyright 2009 Zjut Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Zjut Edu. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Zjut Edu.
 */
package com.springyounger.lottery.dal.dao;

import java.util.Date;
import java.util.List;

import com.springyounger.lottery.dal.dataobject.LotteryPhase;
import com.springyounger.lottery.dal.dataobject.LotteryPrize;
import com.springyounger.lottery.dal.dataobject.LotteryPrizeQuota;
import com.springyounger.lottery.dal.dataobject.LotteryQuota;
import com.springyounger.lottery.dal.dataobject.LotteryStatistical;
import com.springyounger.lottery.dal.dataobject.LotteryWinner;

/**
 * TODO Comment of PhaseDao
 * 
 * @author springyounger
 */
public interface PhaseDao {
    /**
     * 获取所有活动
     * 
     * @return
     */
    List<LotteryPhase> getPhases();

    List<LotteryPhase> getPhases(int pageIndex, int pageSize);

    LotteryPhase getPhaseById(int phaseId);

    LotteryQuota getLotteryQuota(LotteryQuota quota);

    LotteryQuota insertLotteryQuota(LotteryQuota quota);

    int updateLotteryQuota(LotteryQuota quota);

    List<LotteryPrizeQuota> getPrizes(int phaseId, Date grantDate);

    LotteryPrizeQuota getLotteryPrizeQuota(int quotaId);

    int updateLotteryPrizeQuota(LotteryPrizeQuota prize);

    LotteryWinner insertLotteryWinner(LotteryWinner winner);

    int getAllPhaseCount();

    List<LotteryWinner> getLatestWinner(int phaseId, int topSize);

    int getAllWinnerCountById(int userid, int phaseId);

    List<LotteryWinner> getWinnerById(int userid, int phaseId, int pageIndex, int pageSize);

    int getAllPrizesCount();

    List<LotteryPrize> getAllPrizes(int pageIndex, int pageSize);

    LotteryPrize getPrizeById(int prizeId);

    int deletePrize(int prizeId);

    int deletePrizeByPhaseId(int phaseId);

    LotteryPrize insertPrize(LotteryPrize prize);

    int updatePrize(LotteryPrize prize);

    int isExistPrize(LotteryPrize prize);

    int deletePhaseById(int phaseId);

    LotteryPhase insertPhase(LotteryPhase phase);

    int updatePhase(LotteryPhase phase);

    int isExistPhase(String phaseName);

    /**
     * 获取符合条件的所有奖品信息
     * 
     * @param phaseId
     * @return
     */
    List<LotteryPrizeQuota> getAllPrizesByPhaseId(int phaseId);

    /**
     * 获取符合条件的第一条奖品配额
     * 
     * @param prizeId
     * @return
     */
    LotteryPrizeQuota getTopPrizeQuota(int prizeId);

    /**
     * 批量插入配额
     * 
     * @param quotaList
     */
    void batchInsertPrizeQuota(final List<LotteryPrizeQuota> quotaList);

    /**
     * 批量更新配额
     * 
     * @param quotaList
     */
    void batchUpdatePrizeQuota(final List<LotteryPrizeQuota> quotaList);

    /**
     * 统计
     * 
     * @param phaseId
     * @return
     */
    List<LotteryStatistical> getStat(int phaseId);

    /**
     * 统计某天的获奖人数
     * 
     * @param phaseId
     * @param prizeLevel
     * @param lotteryDate
     * @return
     */
    LotteryStatistical getStatValue(int phaseId, String prizeLevel, Date lotteryDate);

    /**
     * 批量创建统计
     * 
     * @param statList
     */
    void batchInsertStat(final List<LotteryStatistical> statList);

    int getStatByDate(int phaseId, Date winDate);
}
